package dp.LIS;

public class leetcode300最长递增子序列 {
    // 经典单串dp，dp[i]依赖dp[i-1 ... 1]
    public int lengthOfLIS(int[] nums) {
        int[] dp = new int[nums.length];
        for (int i = 0; i < nums.length; i++) {
            dp[i] = 1;
        }
        int max = 1;
        for (int i = 1; i < nums.length; i++) {
            for (int j = i; j >= 0; j--) {
                if (nums[i] > nums[j]) {
                    dp[i] = Integer.max(dp[i], dp[j] + 1);
                }
            }
            max = Integer.max(max, dp[i]);
        }
        return max;
    }
}
